package com.gf.help.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.gf.common.util.DateFormater;
import com.gf.help.model.Reply;

public class ReplyMapper implements RowMapper<Reply>{
	private final static String REPLY_ID="id";
	private final static String PUBLISHTIME = "publishTime";
	private final static String REPLIER_ID="replierId";
	private final static String REPLIER_NAME="replierName";
	private final static String QUESTION_ID="questionId";
	private final static String REPLY_CONTENT="content";
	private final static String REPLYPORTRAIT="replierPortrait";
	
	private final static ReplyMapper MAPPER = new ReplyMapper();
	public final static ReplyMapper getMapper() {
		return MAPPER;
	}
	@Override
	public Reply mapRow(ResultSet resultSet, int row) throws SQLException {
		Reply reply=new Reply();
		reply.setContent(resultSet.getString(REPLY_CONTENT));
		reply.setId(resultSet.getLong(REPLY_ID));
		reply.setFormatPublishTime(DateFormater.changeToString(resultSet.getTimestamp(PUBLISHTIME), "yyyy-MM-dd HH:mm"));
		reply.setReplierName(resultSet.getString(REPLIER_NAME));
		reply.setQuestionId(resultSet.getLong(QUESTION_ID));
		reply.setReplierId(resultSet.getLong(REPLIER_ID));
		reply.setReplierPortrait(resultSet.getString(REPLYPORTRAIT));
		return reply;
	}

}
